package yxy.cherry.battle.module.affix.buff;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixContext;
import yxy.cherry.battle.module.affix.AffixFactory;
import yxy.cherry.battle.module.affix.Buff;
import yxy.cherry.battle.module.affix.BuffType;
import yxy.cherry.data.bean.skill;

import java.util.ArrayList;

/**
 * @author James
 * 虚弱（降低对方的输出）
 * @date 2022/2/24 11:57
 **/
@BuffType(Type = AffixFactory.BuffTypeEnum.虚弱)
public class Affix68Weak extends Buff {

    private int getWeakPer(){return getParam(0); }

    public Affix68Weak(Fighter source, Fighter target, skill skilldata, int[] params) {
        super(source, target, skilldata, params);
    }

    @Override
    public boolean exec(Fighter source, Fighter target) {
        AffixContext.AffixAction affixAction = getAffixAction();

        for (AffixContext.AffixTarget affixTarget : affixAction.get目标们()) {
            ArrayList<Long> 伤害流 = affixTarget.get伤害流();
            ArrayList<Long> 结算伤害流 = genReduceDamage(伤害流, affixTarget.getBaseDamageList(), getWeakPer());
            affixTarget.set伤害流(结算伤害流);
            Battle.battleLogger(6,"虚弱：行动者："+affixAction.get行动者().getName()+":被攻击对象："+affixTarget.get目标().getName()+":施法者："+source.getName()+":被施法者："+target.getName()+"伤害："+伤害流.toString()+"虚弱减伤后伤害："+结算伤害流.toString());
        }

        return true;
    }
    @Override
    public BuffType getBuffType(){ return BuffType.减益效果;}

    @Override
    public BuffStateType getBuffStateType(){ return BuffStateType.weakState; }
}
